<?php
use yii\helpers\Url;
use yii\widgets\ActiveForm;

?>
<link href="/backend/css/online-shop.css" rel="stylesheet">
<!-- topbar ends -->
<div class="row">
    <div class="container lh30">
        <a class="topNav" href="<?=Url::toRoute('/system/site/index')?>"><img src="<?=Yii::getAlias('@web/backend/img/home/home.png');?>" alt="首页"/>返回首页</a>
    </div>
</div>

<div class="row nav-brand-bg">
    <div class="container lh30">
        <ul class="nav nav-tabs">
            <li class="active"><a href="<?=Url::toRoute('shop/index')?>">线上店铺</a></li>
            <li><a href="<?=Url::toRoute('shop/servicelist')?>">线上项目</a></li>
        </ul>
    </div>
</div>

<div class="container mt20">
    <?php $form = ActiveForm::begin([
    'id' => 'form_update',
    'options' => [
    'class' => 'form-horizontal',
    'method' => 'post',
    'enctype' => 'multipart/form-data',
    ],
    ]); ?>
    <div class="itemList clearfix">
        <label class="item-name">名称</label>
        <div class="item-txt">
            <input type="hidden" id="bp_id" name="bp_id" value="<?=$get_url_msg['bp_id'] ?>"/>
            <input type="text" name="bp_name" value="<?=$get_url_msg['bp_name'] ?>"/>
        </div>
    </div>
    <div class="itemList clearfix">
        <label class="item-name">封面</label>
        <div class="item-txt current">
            <input type="text" name="bp_name" value="<?=$get_url_msg['bp_name'] ?>"/>
            <input type="file" name="bp_cover" value="">
            <input type="button" value="浏览">
            <input type="hidden" name="oldCover" value="<?=$get_url_msg['bp_cover'] ?>"/>
            <img src="<?=Yii::$app->params['imgUrl'].$get_url_msg['bp_cover']; ?>" style="width: 400px; height:200px;"/>
        </div>
    </div>
    <div class="itemList clearfix">
        <label class="item-name">城市</label>
        <div class="item-txt">
            <select class="mr10">
                <option><?= $get_url_msg['bpArea']['P_NM'];?></option>
            </select>
            <select class="mr10">
                <option><?= $get_url_msg['bpArea']['C_NM'];?></option>
            </select>            <select>
            <option><?= $get_url_msg['bpArea']['A_NM'];?></option>
        </select>
        </div>
    </div>

    <div class="itemList clearfix">
        <label class="item-name">地址</label>
        <div class="item-txt">
            <input type="text"  name="" value="<?= $get_url_msg['bp_address'];?>">
        </div>
    </div>
    <div class="itemList clearfix">
        <label class="item-name">坐标</label>
        <div class="item-txt">
            <input type="text" value="<?= $get_url_msg['latitude'] . ',' . $get_url_msg['longitude'];?>"/>
        </div>
    </div>
    <div class="itemList clearfix">
        <label class="item-name">电话</label>
        <div class="item-txt">
            <input type="text" name="bp_tel" value="<?=$get_url_msg['bp_tel'] ?>"/>
        </div>
    </div>
    <div class="itemList clearfix">
        <label class="item-name">是否验店</label>
        <div class="item-txt">
            <div class="item_radio">
                <input type="radio" name="bp_medal" value="1" <?php if($get_url_msg['bp_medal'] == 1){?>checked="checked"<?php }?> /> 是
                <input type="radio" name="bp_medal" value="0" <?php if($get_url_msg['bp_medal'] == 0){?>checked="checked"<?php }?> /> 否
            </div>
        </div>
    </div>
    <div class="itemList clearfix">
        <label class="item-name">营业时间</label>
        <div class="item-txt">
            <input type="text" name="business_time" value="<?=$get_url_msg['open_time'] ?>至<?=$get_url_msg['close_time'] ?>"/>
        </div>
    </div>
    <div class="itemList clearfix">
        <label class="item-name">起步价</label>
        <div class="item-txt">
            <input type="text" name="low_price" value="<?=$get_url_msg['low_price'] ?>"/>
            <span>起</span>
        </div>
    </div>
    <div class="itemList itemChoice clearfix">
        <label class="item-name">标签</label>
        <div class="item-txt item-choice">
            <ul class="item-txt-ul">
                <?php
                $tag_array = explode(',', $get_url_msg['tags'][0]);
                foreach($tag['result'] as $v){
                    ?>
                <li style="float: left;margin-right: 10px;" class="item-txt-li">
                    <input type="checkbox" style="display: block;" name="tag[]" value="<?= $v['id']?>" <?php echo in_array($v['id'], $tag_array) ? 'checked' : '' ?> />
                    <span><?= $v['title']?></span>
                </li>
                <?php }  ?>
            </ul>
        </div>
    </div>

    <div class="itemList clearfix">
        <label class="item-name">开业年限</label>
        <div class="item-txt">
            <input type="text" name="open_year" value="<?=$get_url_msg['open_year'] ?>"/>
            <span>年</span>
        </div>
    </div>
    <div class="itemList clearfix">
        <label class="item-name">店铺面积</label>
        <div class="item-txt">
            <input type="text" name="shop_area" value="<?=$get_url_msg['shop_area'] ?>"/>
            <span>平方米</span>
        </div>
    </div>
    <div class="itemList clearfix">
        <label class="item-name">项目</label>
        <div class="item-txt">
            <input type="text" name="service_num" value="<?=$get_url_msg['service_num'] ?>"/>
            <span>项</span>
        </div>
    </div>
    <div class="itemList clearfix" style="position: relative">
        <label class="item-name">设备设施</label>
        <div class="item-txt item_StBox">
            <?php if(!empty($get_url_msg['facilities'])){?>
            <label class="item-txt-li">
                <input style="display: block; margin-right: 10px;" type="checkbox" name="facilities[]"
                       value="wifi" <?php foreach ($get_url_msg['facilities'] as $v) {
                        if ($v == 'wifi') {
                            echo 'checked';
                        }
                    } ?>> <span class="mr10">wifi</span></label>
            <label class="item-txt-li"><input style="display: block; margin-right: 10px;"  type="checkbox" name="facilities[]"
                                              value="停车" <?php foreach ($get_url_msg['facilities'] as $v) {
                        if ($v == '停车') {
                            echo 'checked';
                        }
                    } ?>> <span class="mr10">停车</span></label>
            <label class="item-txt-li"><input style="display: block; margin-right: 10px;"  type="checkbox" name="facilities[]"
                                              value="洗浴" <?php foreach ($get_url_msg['facilities'] as $v) {
                        if ($v == '洗浴') {
                            echo 'checked';
                        }
                    } ?>> <span class="mr10">洗浴</span>
            </label>

            <div>
                <?php
                    foreach ($get_url_msg['facilities'] as $v) {
                        if($v != 'wifi' && $v != '停车' && $v != '洗浴'){
                        ?>
                <input type="text" name="facilities[]" style="margin-bottom: 10px;" value="<?=$v ?>"/>
                <span><a href="javascript:;" class="delfacilities">删除</a></span>
                <?php }} ?>
            </div>
            <?php }?>
            <div id="delBox"></div>
            <div class="item-txt">
                <input type="text" class="facilities" id="add_equipmentText" name="">
                <span><a href="javascript:;" class="add_equipment">添加 </a></span>
            </div>
        </div>
    </div>
    <div class="itemList item_ptBox clearfix">
        <label class="item-name">轮播图</label>
        <div class="item-txt">
            <?php foreach($get_url_msg['pics'] as $v){ ?>
            <!-- <input type="hidden" name="oldPhotos[]" value="<?=$v['photo_url'] ?>"/> -->
            <a id="a_<?= $v['photo_id'];?>" class="deletePhoto" href="javascript:void(0)" did="<?=$v['photo_id'] ?>" durl="<?=Url::toRoute("shop/deletephotos") ?>">
            <img id="img_<?= $v['photo_id'];?>" src="<?=Yii::$app->params['imgUrl'].$v['photo_url'];?>" style="width: 300px; height:150px;"/>
            删除</a>
            <?php } ?>
            <div id="bp_photos_box"></div>
            <div>
                <p class="help-block pull-left">*支持JPG，PNG，JPEG格式的图片，大小不超过1M，尺寸为：750X350px</p>
                <button type="button" id="btn_add_photo" class="btn btn-primary btn-sm pull-right"><i class="fa fa-plus"></i></button>
            </div>
            <!-- <input type="file" name="bp_photos[]" multiple="" accept="image/*"> -->
        </div>
    </div>
    <div class="itemList clearfix">
        <label class="item-name">店长电话</label>
        <div class="item-txt">
            <input type="text" name="bp_owner_mobile" value="<?=$get_url_msg['bp_owner_mobile'] ?>"/>
        </div>
    </div>
    <div class="itemList clearfix">
        <label class="item-name">介绍</label>
        <div class="item-txt">
                <textarea id="editor" style="width:600px;height:300px;" name="bp_intro">
                <?=$get_url_msg['bp_intro'] ?>
                </textarea>
        </div>
    </div>

    <div style="padding-left: 156px;">
         <a class="btnBg ml20" style=" height: 40px;">
			<input class="commit" type="submit" value="保存" style="height: 40px;line-height: 40px; background: 0; border: 0;" onclick="return checkTest">
         </a>
         <a class="btnBg bg_rest ml20" style=" height: 40px;">
			<input class="" type="reset" value="取消" style="height: 40px;line-height: 40px; background: 0; border: 0; ">
        </a>
    </div>
    <?php ActiveForm::end(); ?>
</div>
<?php 
$this->registerJsFile('@web/ueditor/utf8-php/ueditor.config.js');
$this->registerJsFile('@web/ueditor/utf8-php/ueditor.all.min.js');
$this->registerJsFile('@web/system/shop/index.js');
?>
